
import { Language } from '../../Frame/Script/const/enumConst';
import { SingletonClass } from '../../Frame/Script/core/singletonClass';
import { ResLoadHelper } from '../../Frame/Script/resLoadHelper';
import { SeatCmd } from '../network/net_proto/protocols/commonRoom';



export default class GameData extends SingletonClass<GameData> {

    public readonly language: Language = Language.Chinese;
    private lanData = null;

    /** 合作模式的数据规格 */
    public readonly TEAMWORk_2: number[] = [18, 12];
    public readonly TEAMWORk_3: number[] = [18, 15];
    public readonly TEAMWORk_4: number[] = [18, 18];
    /** 对战模式的数据规格 */
    public readonly VERSUS: number[] = [18, 12];
    /** 背景格子规格 */
    public readonly GridSize: number = 38;


    /**
     * 游戏模式
     * 1：合作模式
     * 2: 对战模式
     */
    private game_model: number = 1;
    /**
     * 游戏类型
     * 1： 简单
     * 2： 困难
     * 3： 经典
     * 4： 技能
     */
    private game_type: number = 1;
    /** 游戏人数 */
    private game_people_num: number = 2;

    /**
     * 结算类型
     * 0： 平局
     * 1： 胜利
     * 2： 失败
     */
    private settle_type: number = 0;

    /** 座位信息列表 */
    private seats: Array<SeatCmd> = [];
    /** 合作模式消除的行数 */
    public model1_clearLineCount: number = 0;
    public model1_totalScore: number = 0;
    public model1_map: number[][] = null;
    /** 对战模式的攻击数据 */
    public blue_at_count: number = 0;
    public red_at_count: number = 0;

    public user_score_map = { 1: 0, 2: 0, 3: 0, 4: 0 };

    public isGameStart: boolean = false;
    public isGameOver: boolean = false;

    constructor() {
        super();
    }

    protected onInit(...args: any[]): void {
        this.game_model = 1;
        this.game_type = 1;
        let url = "lan/" + this.language;
        ResLoadHelper.loadAssetAsync(url, cc.JsonAsset, (asset: cc.JsonAsset) => {
            this.lanData = asset.json;
        })
    }

    public get LanguageData() {
        return this.lanData;
    }

    public setModelData(model: number) {
        this.game_model = model;
    }

    public getModelData(): number {
        return this.game_model;
    }

    public setTypeData(type: number) {
        this.game_type = type;
    }

    public getTypeData(): number {
        return this.game_type;
    }

    public setPeopleNum(count: number) {
        this.game_people_num = count;
    }

    public getPeopleNum(): number {
        return this.game_people_num;
    }

    public setSettleType(type: number) {
        this.settle_type = type;
    }

    public getSettleType(): number {
        return this.settle_type;
    }

    public getGameSeats() {
        return this.seats;
    }

    public setGameSeats(seats) {
        this.seats = seats;
    }

    protected onDestroy(): void {

    }
}


